package com.lhk;

import com.sun.org.apache.xpath.internal.res.XPATHErrorResources_ja;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;


public class Test01 {
    static Configuration conf =new Configuration();
    static FileSystem fs;


    public static void  main(String [] args)throws Exception{
        Getlist();
       // xiazai();
       // shangChuan();
    }

    //查看
    public static void Getlist()throws Exception{
        fs = FileSystem.get(conf);
        Path path = new Path("/cjy");
        FileStatus[] list = fs.listStatus(path);

        for (FileStatus f : list){
            System.out.println(f);
        }
    }
   //下载
    public static void xiazai() throws Exception{
        fs=FileSystem.get(conf);
        fs.copyToLocalFile(false,new Path("/Yday.txt"),new Path("D:/Yday"),true);
        fs.close();
        System.out.println("下载成功");
    }

     //上传
    public static void shangChuan() throws IOException {
        fs = FileSystem.get(conf);
        fs.copyFromLocalFile(false,new Path("D:/emp.json"), new Path("/cjy"));
        fs.close();
        System.out.println("上传成功");
    }
}
